import 'package:get/get.dart';
import 'package:share_fit/app/controllers/base/base_controller.dart';
import 'package:share_fit/app/controllers/home/home_const.dart';
import 'package:share_fit/app/ute/uteped_const.dart';

import 'state.dart';

class MenstrualLogic extends BaseController {
  final String mSetMenstrualNotifyAbility = "setMenstrualNotifyAbility";

  final MenstrualState state = MenstrualState();

  goBack() {
    Get.back();
  }

  void openMenstrual(bool value) async {
    state.openMenstrual = value;
    save(HomeConst.cycleCalendarEnable, state.openMenstrual, global: true);
    update(['is_open_menstrual']);

    Map map = {
      UTEPedConst.keyEnable: value,
    };
    await bRemoteReqAsync(mSetMenstrualNotifyAbility, {'map': map});
  }

  @override
  String getRemotePath() {
    return UTEPedConst.pathMenstrual;
  }

  @override
  void initState() {
    state.openMenstrual = read(HomeConst.cycleCalendarEnable, defaultValue: false, global: true);
    update(['is_open_menstrual']);
  }

  @override
  void onRemoteEvent(event, method) {
    // TODO: implement onRemoteEvent
  }
}
